from eth.addressHistory import get_transactions,getTransferByAdress,get_candlestick_data
from utils.xlsxUtils import write_xlsx_file
from utils.FileUtil import FileUtil
from eth.buyContract import swap_dai


#获取交易记录并根据地址保存成xlsx
def transactionByAddress(address1,startblock=0,endblock=99999999):
    transactions = get_transactions(address1,startblock,endblock)
    handler = []
    rows = []
    
    for tx in transactions:
        if len(handler)==0:
            for key in tx.keys():
                handler.append(key)
        row = []
        for value in handler:
            row.append(tx[value])
        rows.append(row)
    write_xlsx_file("测试啦",handler,rows,address1+".xlsx")

# transactionByAddress("0x0eee1bbb6a0d643211238e1fdf24ce7b3c29a7fe")
# get_transfer("0x471A202f69D6e975DA55E363daB1bDB2e86E0c0f")
# getAbiByAdress("0x471A202f69D6e975DA55E363daB1bDB2e86E0c0f")
# getTransferByAdress("0x471A202f69D6e975DA55E363daB1bDB2e86E0c0f")
# get_candlestick_data("0x471A202f69D6e975DA55E363daB1bDB2e86E0c0f")

#调用文件
# f = FileUtil()
# f.write_file("test","test/1.txt")
# f.delete_path("D:\\Users\\Desktop\\骑士团.txt")

# swap_dai("0x471A202f69D6e975DA55E363daB1bDB2e86E0c0f",10000000)